#ifndef GAMEWORLD_H
#define GAMEWORLD_H

#include <vector>
#include <memory>
#include <string>
#include "GameObject.h"
#include "../Camera/Camera.h"

// Game world manager
class GameWorld {
public:
    GameWorld();
    ~GameWorld();

    // Game object management
    GameObject* createGameObject(const std::string& name = "GameObject");
    void destroyGameObject(GameObject* gameObject);
    void destroyGameObject(const std::string& name);
    
    GameObject* findGameObject(const std::string& name);
    std::vector<GameObject*> findGameObjectsWithTag(const std::string& tag);
      // Update and rendering
    void update(float deltaTime);
    void render();
    void render(Camera* camera);  // Render with camera transformation
    
    // Camera management
    void setCamera(Camera* camera) { camera_ = camera; }
    Camera* getCamera() const { return camera_; }
    
    // Collision detection
    std::vector<GameObject*> checkCollisions(GameObject* gameObject);
    
    void clear();
    
    const std::vector<std::unique_ptr<GameObject>>& getAllGameObjects() const;

private:
    std::vector<std::unique_ptr<GameObject>> gameObjects_;
    std::vector<std::unique_ptr<GameObject>> toDestroy_;
    Camera* camera_;  // Optional camera for rendering
    
    void processDestroyQueue();
};

#endif // GAMEWORLD_H
